home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / ntjbnd.arc / JUL-BND.PAS
Pascal/Delphi Source File  |  1989-03-25  |  10KB  |  370 lines

  1. Uses Dos;
  2.  
  3.  
  4. Type
  5.  
  6. HalfRegType = record
  7.                Al,Ah,Bl,Bh,Cl,Ch,Dl,Dh:byte
  8.               end;
  9.  
  10. MyWord      = record
  11.                wh,wl : byte;
  12.               end;
  13.  
  14. Longs       = record
  15.                ah,al,bh,bl:byte;
  16.               end;
  17.  
  18. PropCall    = record
  19.                native    : MyWord;
  20.                func      : Byte;      { func 0x3e }
  21.                objtyp    : MyWord;
  22.                objnamel  : Byte;
  23.                objname   : array[1..512] of byte;
  24.               end;
  25.  
  26. CreateCall = record
  27.               native   : MyWord;
  28.               func     : Byte;
  29.               flags    : Byte;
  30.               security : Byte;
  31.               objtyp   : MyWord;
  32.               objnamel : byte;
  33.               objname  : array[1..48] of byte;
  34.              end;
  35.  
  36. CreateRply = record
  37.               native   : MyWord;
  38.              end;
  39.  
  40. ReadPropertyc = record
  41.                  native : MyWord;
  42.                  func   : byte;
  43.                  objTyp : MyWord;
  44.                  objNmel: byte;
  45.                  objName: array[1..200] of byte;
  46.                 end;
  47.  
  48. ReadPropertyr = record
  49.                  native : MyWord;
  50.                  data   : array[1..128] of byte;
  51.                  more   : byte;
  52.                  flags  : byte;
  53.                 end;
  54.  
  55.  
  56. { now, some common variable definitions }
  57. var
  58. regs : Registers;  { innate to Turbo Pascal v4.0 and v5.0 }
  59. hr   : HalfRegType absolute Regs;
  60. sc   : CreateCall;
  61. sr   : CreateRply;
  62. pc   : PropCall;
  63. rpc  : ReadPropertyc;
  64. rpr  : ReadPropertyr;
  65.  
  66. a,b    : integer;
  67.  
  68. Procedure CheckSuccess;
  69. Begin
  70. { this routine will look at the current value of hr.al (al part of }
  71. { AX register) and determine proper message                        }
  72.  
  73. If hr.al = 0 then       { if we can create the lock... }
  74. Begin
  75.    WriteLn('Operation successfully completed!');
  76. End
  77. ELSE { there was an error, print it out if a common one }
  78.    Case hr.al of
  79.    237: WriteLn('Property already exists');
  80.    238: WriteLn('Object already exists');
  81.    239: WriteLn('Object name contains illegal characters');
  82.    240: WriteLn('Attempt to use wild cards in wrong place');
  83.    245: WriteLn('No Object Creation or Change privileges');
  84.    247: WriteLn('No Property Creation or Change privileges for object');
  85.    248: WriteLn('No Write privileges for property');
  86.    249: WriteLn('No Read privileges for property');
  87.    251: WriteLn('No such Property');
  88.    252: WriteLn('No such Object');
  89.    253: WriteLn('Unknown bindery request');
  90.    254: WriteLn('Bindery temporarily locked, try later');
  91.    255: WriteLn('Unrecoverable/Unknown error');
  92.    else WriteLn('Unknown error code: ',hr.al);
  93.    end; {of case}
  94.  
  95.  
  96. End; { of CheckSuccess }
  97.  
  98. Procedure CreateObject;
  99.  
  100. var
  101. user : Longs;
  102. Begin
  103.  
  104.    With sc do
  105.    Begin
  106.          native.wh := $07;   { set up request packet size }
  107.                              { note that this size will vary with }
  108.                              { the length of the object name }
  109.          native.wl := $00;
  110.       sr.native.wh := $FF;   { set up reply packet size   }
  111.       sr.native.wl := $00;
  112.               func := $32;   { create object   }
  113.              flags := $01;   { dynamic         }
  114.           security := $11;   { Write Security is most significant  }
  115.                              { nybble of the security byte: }
  116.                              { 0=anyone, even if not logged in }
  117.                              { 1=anyone logged in              }
  118.                              { 2=any object or supervisor      }
  119.                              { 3=only supervisors              }
  120.                              { 4=bindery only                  }
  121.                              { Read Security is least significant  }
  122.                              { nybble of the security byte: }
  123.                              { 0=anyone, even if not logged in }
  124.                              { 1=anyone logged in              }
  125.                              { 2=any object or supervisor      }
  126.                              { 3=only supervisors              }
  127.                              { 4=bindery only                  }
  128.          { thus security = 0x11 write/read by anyone logged in }
  129.          objtyp.wh := $88;   { set up object type }
  130.          objtyp.wl := $88;
  131.           objnamel := 1;     { set up obj name length that follows }
  132.         objname[1] := 74;    { define a name "J", cute huh? 74=ASCII J }
  133.    end;  { of with sc }
  134.  
  135.    hr.ah := $E3;             { 0xE3 is Novell's API code }
  136.  
  137.    With regs do
  138.    Begin
  139.          DS := seg(sc); { set up pointers to seg:ofs of request packet }
  140.          SI := ofs(sc);
  141.          ES := seg(sr); { set up pointers to seg:ofs of reply packet }
  142.          DI := ofs(sr);
  143.    end;  { of regs }
  144.  
  145.    MsDos(regs);         { call DOS, try to create }
  146.  
  147.    CheckSuccess;
  148.  
  149. End;  { of CreateObject }
  150.  
  151. Procedure CreateProp;
  152. Begin
  153.  
  154. { note this only creates the property, no value has yet been }
  155. { established }
  156.  
  157. With pc do
  158. Begin
  159.  
  160.     sr.native.wl := $00;
  161.     sr.native.wh := $FF;
  162.  
  163.        native.wl := $00;
  164.        native.wh :=  21+17; { 17 is length of the name, the only variable }
  165.                             { in the length of the request packet }
  166.             Func := $39;    { add a property to an object }
  167.        objtyp.wl := $88;
  168.        objtyp.wh := $88;
  169.  
  170.         ObjNamel := 1;  { object name length }
  171.  
  172.       ObjName[1] := 74; { the name of "J" again }
  173.  
  174.     ObjName[1+1] := $00; { 00= Static Flag and an item type object }
  175.                          { 01= Dynamic Flag, the byte immediately }
  176.                          { 02= Static Flag an a set type object }
  177.                          {     following the last character of the }
  178.                          {     name, hence 1+1 for clarity only }
  179.     ObjName[1+2] := $11;{ Security, 11 = any logged in }
  180.  
  181.     ObjName[1+3] := 14; { PropName Length                  }
  182.     ObjName[1+4] :=$49; { I }
  183.     ObjName[1+5] :=$44; { D }
  184.     ObjName[1+6] :=$45; { E }
  185.     ObjName[1+7] :=$4E; { N }
  186.     ObjName[1+8] :=$54; { T }
  187.     ObjName[1+9] :=$49; { I }
  188.     ObjName[1+10]:=$46; { F }
  189.     ObjName[1+11]:=$49; { I }
  190.     ObjName[1+12]:=$43; { C }
  191.     ObjName[1+13]:=$41; { A }
  192.     ObjName[1+14]:=$54; { T }
  193.     ObjName[1+15]:=$49; { I }
  194.     ObjName[1+16]:=$4F; { O }
  195.     ObjName[1+17]:=$4E; { N }
  196.  
  197. end; { of with pc }
  198.  
  199. with regs do
  200. Begin
  201.   AX:=$E300;
  202.  
  203.   ES:=Seg(sr);
  204.   DI:=Ofs(sr);
  205.  
  206.   DS:=Seg(pc);
  207.   SI:=Ofs(pc);
  208.  
  209. end; { of with regs }
  210.  
  211.   MsDos(regs);
  212.  
  213.   CheckSuccess;
  214.  
  215. End;  { of CreateProp }
  216.  
  217.  
  218. Procedure WriteProp;
  219. Begin
  220.  
  221. With pc do
  222. Begin
  223.  
  224.     sr.native.wl := $00;
  225.     sr.native.wh := $FF;
  226.  
  227.        native.wl := $00;
  228.        native.wh :=  135+1+14; { fixed length + object name + property }
  229.                                { name length }
  230.             Func := $3E;{ Write a Property Value }
  231.        objtyp.wl := $88;{ object type }
  232.        objtyp.wh := $88;
  233.  
  234.         ObjNamel := 1;  { object name length }
  235.  
  236.       ObjName[1] := 74; { object name }
  237.  
  238.     ObjName[1+1] := 1;  { Segment Number }
  239.     ObjName[1+2] := 0;  { More Flag, 0 = last segment, any existing }
  240.                         { segments beyond this one will be deleted  }
  241.  
  242.  
  243.     ObjName[1+3] := 14; { PropName Length                  }
  244.     ObjName[1+4] :=$49; { I }
  245.     ObjName[1+5] :=$44; { D }
  246.     ObjName[1+6] :=$45; { E }
  247.     ObjName[1+7] :=$4E; { N }
  248.     ObjName[1+8] :=$54; { T }
  249.     ObjName[1+9] :=$49; { I }
  250.     ObjName[1+10]:=$46; { F }
  251.     ObjName[1+11]:=$49; { I }
  252.     ObjName[1+12]:=$43; { C }
  253.     ObjName[1+13]:=$41; { A }
  254.     ObjName[1+14]:=$54; { T }
  255.     ObjName[1+15]:=$49; { I }
  256.     ObjName[1+16]:=$4F; { O }
  257.     ObjName[1+17]:=$4E; { N }
  258.  
  259.     For a:=1 to 128 do
  260.        ObjName[1+17+a] := 0;  {Null it out, could fill with any info }
  261.  
  262.   End; { of with sc }
  263.  
  264.  
  265. With regs do
  266. Begin
  267.  
  268.   AX:=$E300;
  269.  
  270.   ES:=Seg(sr);
  271.   DI:=Ofs(sr);
  272.  
  273.   DS:=Seg(pc);
  274.   SI:=Ofs(pc);
  275.  
  276. End; { of with regs }
  277.  
  278.   MsDos(regs);
  279.  
  280.   CheckSuccess;
  281.  
  282.  
  283. End;  { of WriteProp }
  284.  
  285.  
  286. Procedure ReadProp;
  287. Begin
  288.  
  289. with rpc do
  290. Begin
  291.          native.wh := 6+1+14; { 6=fixed, 1=object name, 14=property name }
  292.          native.wl := $00;
  293.  
  294.          fillchar(rpr.data,sizeof(rpr.data),0); { ensure the reply buffer }
  295.                                                 { starts out as all nulls }
  296.  
  297.      rpr.native.wh := 130;
  298.      rpr.native.wl := $00;
  299.               func := $3D; { Read a Property Value }
  300.          objtyp.wl := $88;
  301.          objtyp.wh := $88;
  302.            objnmel := 1;
  303.         objname[1] := 74;
  304.  
  305.       objname[1+1] := 1;  { Segment to read }
  306.  
  307.     ObjName[1+2] := 14; { PropName Length                  }
  308.     ObjName[1+3] :=$49; { I }
  309.     ObjName[1+4] :=$44; { D }
  310.     ObjName[1+5] :=$45; { E }
  311.     ObjName[1+6] :=$4E; { N }
  312.     ObjName[1+7] :=$54; { T }
  313.     ObjName[1+8] :=$49; { I }
  314.     ObjName[1+9] :=$46; { F }
  315.     ObjName[1+10]:=$49; { I }
  316.     ObjName[1+11]:=$43; { C }
  317.     ObjName[1+12]:=$41; { A }
  318.     ObjName[1+13]:=$54; { T }
  319.     ObjName[1+14]:=$49; { I }
  320.     ObjName[1+15]:=$4F; { O }
  321.     ObjName[1+16]:=$4E; { N }
  322.  
  323. End; { of with rpc }
  324.  
  325. With regs do
  326. Begin
  327.         AX    := $E300;
  328.         DS    := Seg(rpc);
  329.         SI    := Ofs(rpc);
  330.         ES    := Seg(rpr);
  331.         DI    := Ofs(rpr);
  332. End;
  333.  
  334. MsDos(Regs);
  335.  
  336. CheckSuccess;
  337.  
  338. End;  { end of ReadProp }
  339.  
  340.  
  341.  
  342.  
  343.  
  344. Begin
  345. {
  346. CreateObject;
  347. CreateProp;
  348. WriteProp;
  349. ReadProp;
  350.  }
  351.  
  352.  
  353. regs.ax:=$0010;
  354. intr($10,regs);
  355.  
  356. a:=16;
  357. for b:=639 downto 0 do
  358. begin
  359. a:=a-1;
  360. regs.ax:=$0c00+a;
  361. if a=0 then a:=16;
  362. regs.bx:=0;
  363. regs.dx:=10;
  364. regs.cx:=b;
  365. intr($10,regs);
  366. end;
  367.  
  368.  
  369.  
  370. End.